<template>
    <div>
    <table>
        <tr>
            <td>用户名</td>
            <input type="text" v-model="username">
        </tr>
        <tr>
            <td>密码</td>
            <input type="password" v-model="password">
        </tr>

        <Button type="submit" @click="login">登录</Button>

        

    </table>
       

    </div>
</template>

<script>
export default {
    data () {
        return {
            username:'',
            password:''
        }
    },
    methods: {
         login(){
             this.axios.get('http://127.0.0.1:8000/myupup/myupdelogin/',{params:{'username':this.username,'password':this.password}})
             .then(result=>{
                 if(result.data.code==200){
                     //登录成功
                     localStorage.setItem('username',result.data.username)
                     localStorage.setItem('uid',result.data.uid)
                     
                     this.$Message(result.data.message)
                     this.$router.push('/myupgoods')
 
                 }
                 else{
                     this.$Message(result.data.msg)
                 }
                 console.log(result)
            
             })
       }
        
    },

}
</script>

<style>

</style>

